package com.smartstate.ems.util;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MyExpressionUtil {

    /**
     * 匹配 #{关键字}
     *
     * @param expression
     * @return
     */
    public static List<String> getExpressionParams(String expression) {
        Pattern pattern = Pattern.compile("\\$\\{[^\\}]+\\}");
        Matcher matcher = pattern.matcher(expression);
        List<String> result = new ArrayList<>();
        //循环，字符串中有多少个符合的，就循环多少次
        while (matcher.find()) {
            //每一个符合正则的字符串
            String e = matcher.group();
            //截取出括号中的内容
            String substring = e.substring(2, e.length() - 1);
            result.add(substring);
        }
        return result;
    }

    public static String quChu(String str) {
        String regEx1 = "[${]";
        str = str.replaceAll(regEx1, "L");
        String regEx = "[${}]";
        return str.replaceAll(regEx, "");

    }


}
